# Contributor: rubicon <rubicon@mailo.com>
# Maintainer:
pkgname=ocaml-containers
pkgver=3.7
pkgrel=1
pkgdesc="Modular, clean and powerful extension of the OCaml standard library"
url="https://github.com/c-cube/ocaml-containers/"
arch="all !riscv64"  # limited by ocaml aport
license="BSD-2-Clause"
depends="ocaml-runtime"
depends_dev="$pkgname=$pkgver-r$pkgrel ocaml-compiler-libs"
makedepends="$depends_dev dune dune-configurator ocaml"
checkdepends="
	ocaml-csexp-dev
	ocaml-gen-dev
	ocaml-iter-dev
	ocaml-ounit-dev
	ocaml-qcheck-dev
	ocaml-qtest-dev
	ocaml-uutf-dev
	"
options="!check"
subpackages="$pkgname-top $pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/c-cube/ocaml-containers/archive/v$pkgver.tar.gz
	use-built-in-libraries.patch
	"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	dune build --release --verbose
}

check() {
	dune runtest --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--docdir=/.omit
	rm -Rf "$pkgdir"/.omit
}

top() {
	pkgdesc="$pkgdesc (toplevel pretty-printers)"
	depends="$depends ocaml-compiler-libs"

	amove usr/lib/ocaml/containers-data/top/
	amove usr/lib/ocaml/containers/top/
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
70f99a062f7696d4ed7a6336532261c93c49a9858a84a12f7f3d60190a5c664198e70be6281dc7c7932c07325dc9c579ff521367e4c7e083566910ba0f9ea760  ocaml-containers-3.7.tar.gz
f8404c969bfc5b03b3c8d786b04ff03e24a3eb7e75d3d1d9b84922ca78ffe4223229e8a823e401bbd967b4548d211481d4c6efefc48a603bf5d5f0b9fad239ac  use-built-in-libraries.patch
"
